package com.thread.threadfirst.marvel.citymaster.conf;

import org.springframework.beans.factory.BeanFactory;


/**
 *@author vincen 
 */
public class BeanFactoryHolder {

    private static BeanFactory beanFactory;


    /**
     *
     * @param beanFactory
     */
    public BeanFactoryHolder(BeanFactory beanFactory){
        BeanFactoryHolder.beanFactory=beanFactory;
    }

    /**
     * 	<T> T getBean(Class<T> requiredType) throws BeansException;
     * @param clazz
     * @param <T>
     * @return
     */
    public static <T> T getBean(Class<T> clazz){
        return beanFactory.getBean(clazz);
    }

    /**
     * Object getBean(String name, Object... args) throws BeansException;
     * @param name
     * @param <T>
     * @return
     */
    public static <T> T getBean(String name){
        return (T) beanFactory.getBean(name);
    }

}
